<?php
   function match_chinese($chars,$encoding='utf8')
    {
        $pattern =($encoding=='utf8')?'/[\x{4e00}-\x{9fa5}a-zA-Z0-9]/u':'/[\x80-\xFF]/';
        preg_match_all($pattern,$chars,$result);
        $temp =join('',$result[0]);
        return $temp;
    }

 function getDistance2($lat1, $lng1, $lat2, $lng2){ 
         define('PI',3.1415926535898);
         define('EARTH_RADIUS',6378.137);
         $radLat1 = $lat1 * (PI / 180);
        $radLat2 = $lat2 * (PI / 180);
         
         $a = $radLat1 - $radLat2; 
         $b = ($lng1 * (PI / 180)) - ($lng2 * (PI / 180)); 
        
         $s = 2 * asin(sqrt(pow(sin($a/2),2) + cos($radLat1)*cos($radLat2)*pow(sin($b/2),2))); 
         $s = $s * EARTH_RADIUS; 
         $s = round($s * 10000) / 10000; 
         return $s; 
     }